/*
 * Roboviz.h
 *
 *  Created on: Aug 17, 2011
 *      Author: adailton
 */

#ifndef ROBOVIZ_H_
#define ROBOVIZ_H_

#include <string>
#include <vector>

#include "../../Matematica/include/Coordenada2d.h"
#include "../../Matematica/include/Coordenada3d.h"
#include "../../Conexao/include/ConexaoUDP.h"

#include "../../Matematica/include/Util.h"

typedef struct _ROBOVIZ_COR
{
    int r;
    int g;
    int b;
}RobovizCor;

class Roboviz
{
    public:
        static Roboviz& getInstance();

        void ativo(bool ativo);
        void setNumeroJogador(int num);
        void conectar(std::string host, std::string port);

        void swap();
        void drawEsfera(Coordenada3d centro, float raio, RobovizCor cor, std::string nome);
        void drawCirculo(Coordenada2d centro, float raio, float espessura, RobovizCor cor, std::string nome);
        void drawLinha(Coordenada3d inicio, Coordenada3d fim, float espessura, RobovizCor cor, std::string nome);
        void drawPonto(Coordenada3d ponto, float tamanho, RobovizCor cor, std::string nome);
        void drawPoligono(std::vector<Coordenada3d> vertice, RobovizCor cor, std::string nome);

        void drawAnotacao(std::string texto, Coordenada3d ponto, RobovizCor cor, std::string nome);
        void drawAgenteAnotacao(std::string texto, bool leftTime, int numAgente, RobovizCor cor);

    private:
        Roboviz();
        Roboviz(const Roboviz& r);
        Roboviz& operator= (const Roboviz& r);

        int writeCharToBuf(unsigned char* buf, unsigned char value);
        int writeFloatToBuf(unsigned char* buf, float value);
        int writeColorToBuf(unsigned char* buf, const float* color, int channels);
        int writeStringToBuf(unsigned char* buf, const std::string* text);

    private:
        bool              isAtivo;
        int               mNumeroJogador;
        ConexaoUDP* mConexao;

        static Roboviz*         mInstance;
};

#endif /* ROBOVIZ_H_ */
